﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SMTC.Model.Model;
using SMTC.WebCommon.Common;
using SMTC.BO.HolidayMangement;
public partial class BaseInfoManagement_BUInfoMaintain : BasePage
{
    HolidayProccessServices _services = new HolidayProccessServices();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request["action"] != null && Request["action"].ToString() == "select")
        {
            this.gvHoliday.Columns[0].Visible = true;
            this.gvHoliday.Columns[5].Visible = false;
            btnVendorContactOK.Visible = true;
            btnVendorContactCancel.Visible = true;
            title.Text = "请选择BU";
        }
    }

    protected void gvHoliday_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "Del")
        {
            if (_services.DeleteHoliday(DateTime.Parse(e.CommandArgument.ToString())) == true)
            {
                this.ShowMessage(Resources.Resource.VacationInfoDeleteSuccess);//休假信息删除成功！
            }
            else
            {
                this.ShowMessage(Resources.Resource.VacationInfoDeleteFailed);//"休假信息删除失败！"
            }

            gvHoliday.DataBind();
        }
    }

    protected void btn_Save_Click(object sender, EventArgs e)
    {
        SMT_HolidayModel holiday = new SMT_HolidayModel();
        holiday.HolidayDate = DateTime.Parse(txt_HolidayDate.Value.Trim());
        holiday.Discrib = txt_Discrib.Text.Trim();
        holiday.ModifyPerson = this.UserName;

        if (_services.InsertOrUpdate(holiday) == true)
        {
            this.ShowMessage(Resources.Resource.VacationInfoAddFailed);//"添加休假信息成功！"
        }
        gvHoliday.DataBind();
    }

}